package day0920;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class StudentDaoCollection  implements  StudentDao{
    Collection<String>  collection=  new ArrayList<>();//1.集合

    public void showAll() {//B.打印集合所有元素
        Iterator<String> it=collection.iterator();//A.iterator
        while(it.hasNext()) {//B.
            String name=it.next();//C.
            System.out.println("name = " + name);
        }
    }
    public void insertStudent(String name) {//A.给集合中放元素
        collection.add(name);
    }

    public boolean isExist(String name) {//c.判断集合是否有某个元素
        return collection.contains(name);
    }
}
